<?php
/**
 * Created by PhpStorm.
 * User: chentaohua
 * Date: 2019/1/7
 * Time: 16:27
 * 留言列表
 */

namespace app\admin\controller;

class Message extends Common{

    // 列出所有留言信息
    public function lst(){

        $messageModel = new \app\admin\model\Message;
        $messageObj = $messageModel::with(['member']) -> paginate(config('common_page'));
        $messages = [];
        foreach ($messageObj as $item){
            $messages[] = $item -> toArray();
        }

        foreach ($messages as $key => &$value) {
            if(!empty($value['time'])){
                $value['time'] = date('Y-m-d H:i:s',$value['time']);
            }else{
                $value['time'] = '';
            }
        }

        $this -> assign('messages',$messages);
        $this -> assign('page',$messageObj -> render());
        return $this -> fetch();
    }
}